home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / tex / style / misc / weekday.sty < prev    next >
Text File  |  1995-11-25  |  3KB  |  75 lines

  1. % Save file as: WEEKDAY.STY            Source: FILESERV@SHSU.BITNET  
  2. %% WEEKDAY.STY -- original source: Dimitri Vulis <DLV@CUNYVMS1.BITNET> with
  3. %%  modifications by George D. Greenwade <BED_GDG@SHSU.BITNET>, and gracious
  4. %%  assistance from Bernhard Schroeder <UPK002@DBNRHRZ1.BITNET>, Hunter
  5. %%  Goatley <GOATHUNTER@WKUVX1.BITNET>, and others via INFO-TeX/comp.text.tex.
  6. %%  21-FEB-1991 17:42:37
  7. %% 
  8. %% Usage: \weekday{yyyy}{mm}{dd} (where "yyyy" is a year, "mm" is the numeric
  9. %%        equilavent of the month, and "dd" is the specific calendar date
  10. %%        which may be one or two numbers) yields the weekday associated with
  11. %%        the date provided (i.e., Sunday, Monday, ...).  May pass \year,
  12. %%        \month, and \day to generate today's weekday.
  13. %% 
  14. %%    --  \weekdaydate{yyyy}{mm}{dd} yields result of \weekday, as well as the
  15. %%        calendar date (i.e., \weekdaydate{1991}{02}{21} yields Thursday,
  16. %%        February 21, 1991).  (NOTE: syntax is changed from \weekdaydisplay
  17. %%        to \weekdaydate to make it a little more rememberable)
  18. %%
  19. %% May be used as a TeX macro or as a LaTeX style, from what I can tell.
  20. %% Please report any enhancements or bugs you come across so they can be
  21. %%    posted in FILESERV's STYle archives.  George <BED_GDG@SHSU.BITNET>
  22. %%
  23. \newcount\wwwy
  24. \newcount\wwwm
  25. \newcount\wwwd
  26. \newcount\wwwc
  27. \newcount\wwwt
  28. \newcount\wwws
  29.  
  30. \def\weekday@{%
  31. \wwwc=\wwwy
  32. \divide\wwwc100\relax
  33. \wwwt=-\wwwc
  34. \multiply\wwwt100\relax
  35. \advance\wwwy\wwwt
  36. \wwws=\wwwy
  37. \multiply\wwws1461\relax
  38. \divide\wwws4\relax
  39. \wwwt=\wwwm
  40. \multiply\wwwt764\relax
  41. \divide\wwwt25\relax
  42. \advance\wwws\wwwt
  43. \advance\wwws\wwwd
  44. \ifnum\wwwm>\tw@\advance\wwws\thr@@\else\weekday@@\fi
  45. \wwwt=-\wwws
  46. \divide\wwwt7\relax
  47. \multiply\wwwt7\relax
  48. \advance\wwws\wwwt
  49. }
  50.  
  51. % By the year 2000 we ought to examine \wwwc as well
  52.  
  53. \def\weekday@@{%
  54. \wwwt=\wwwy
  55. \divide\wwwt4\relax
  56. \multiply\wwwt4\relax
  57. \advance\wwwt-\wwwy
  58. \ifnum\wwwt=\z@\advance\wwws4\else\advance\wwws5\fi
  59. }
  60.  
  61. \def\weekday#1#2#3{% year, month 1--12, day 1--31
  62. \wwwy=#1\relax\wwwm=#2\relax\wwwd=#3\relax \weekday@
  63. \ifcase\wwws Sunday\or
  64.  Monday\or Tuesday\or Wednesday\or Thursday\or Friday\or Saturday\fi}
  65.  
  66. \def\weekdaydate#1#2#3{% year, month 1--12, day 1--31
  67. \wwwy=#1\relax\wwwm=#2\relax\wwwd=#3\relax\weekday@
  68. \ifcase\wwws Sunday,\or
  69. Monday,\or Tuesday,\or Wednesday,\or Thursday,\or Friday,\or Saturday,\fi
  70. \space
  71. \ifcase #2\or
  72.  January\or February\or March\or April\or May\or June\or
  73.  July\or August\or September\or October\or November\or December\fi
  74. \space\number#3, \space\number#1}  % Here I (Bernhard) inserted \number 
  75.